using System;
using System.Data;
using System.Data.Common;
using System.Configuration;
using System.Data.SqlClient;

using SIS.ENT;


namespace SIS.DAL
{
    /// <summary>
    /// The SchoolContactTableDB class is responsible for interacting with the database to retrieve and store information
    /// about SchoolContactTable objects.
    /// </summary>
    public class SchoolContactTableDB
    {
        #region "Public Methods"

        /// <summary>
        /// Gets an instance of SchoolContactTable from the underlying datasource.
        /// </summary>
        /// <param name="schoolContactKey">The unique SchoolContactKey of the SchoolContactTable in the database.</param>
        /// <returns>An SchoolContactTable when the SchoolContactKey was found in the database, or null otherwise.</returns>
        public static SchoolContactTable GetItem(int schoolContactKey)
        {
            SchoolContactTable mySchoolContactTable = null;
            using (SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["sis.dbconn"].ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("sprocSchoolContactTableSelectSingleItem", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;
                    myCommand.Parameters.AddWithValue("@schoolContactKey", schoolContactKey);

                    myConnection.Open();
                    using (SqlDataReader myReader = myCommand.ExecuteReader())
                    {
                        if (myReader.Read())
                        {
                            mySchoolContactTable = FillDataRecord(myReader);
                        }
                        myReader.Close();
                    }
                    myConnection.Close();
                }
                return mySchoolContactTable;
            }
        }

        /// <summary>
        /// Returns a list with SchoolContactTable objects.
        /// </summary>
        /// <returns>A generics List with the SchoolContactTable objects.</returns>
        public static SchoolContactTableList GetList()
        {
            SchoolContactTableList tempList = new SchoolContactTableList();
            using (SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["sis.dbconn"].ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("sprocSchoolContactTableSelectList", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    myConnection.Open();
                    using (SqlDataReader myReader = myCommand.ExecuteReader())
                    {
                        if (myReader.HasRows)
                        {
                            while (myReader.Read())
                            {
                                tempList.Add(FillDataRecord(myReader));
                            }
                        }
                        myReader.Close();
                    }
                }
            }
            return tempList;
        }

        /// <summary>
        /// Returns a list with SchoolContactTable objects.
        /// </summary>
        /// <returns>A generics List with the SchoolContactTable objects.</returns>
        public static SchoolContactTableList GetListBySchoolKey(int SchoolKey)
        {
            SchoolContactTableList tempList = new SchoolContactTableList();
            using (SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["sis.dbconn"].ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("sprocSchoolContactTableSelectListBySchoolKey", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;
                    myCommand.Parameters.AddWithValue("@schoolKey", SchoolKey);
                    myConnection.Open();
                    using (SqlDataReader myReader = myCommand.ExecuteReader())
                    {
                        if (myReader.HasRows)
                        {
                            while (myReader.Read())
                            {
                                tempList.Add(FillDataRecord(myReader));
                            }
                        }
                        myReader.Close();
                    }
                }
                return tempList;
            }
        }

        /// <summary>
        /// Saves a SchoolContactTable in the database.
        /// </summary>
        /// <param name="mySchoolContactTable">The SchoolContactTable instance to save.</param>
        /// <returns>The new SchoolContactKey if the SchoolContactTable is new in the database or the existing SchoolContactKey when an item was updated.</returns>
        public static int Save(SchoolContactTable mySchoolContactTable)
        {
            int result = 0;
            using (SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["sis.dbconn"].ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("sprocSchoolContactTableInsertUpdateSingleItem", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    if (mySchoolContactTable.SchoolContactKey == -1)
                    {
                        myCommand.Parameters.AddWithValue("@schoolContactKey", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@schoolContactKey", mySchoolContactTable.SchoolContactKey);
                    }
                    if (mySchoolContactTable.SchoolKey == null)
                    {
                        myCommand.Parameters.AddWithValue("@schoolKey", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@schoolKey", mySchoolContactTable.SchoolKey);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.Contact1Title))
                    {
                        myCommand.Parameters.AddWithValue("@contact1Title", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contact1Title", mySchoolContactTable.Contact1Title);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.ContactNo1))
                    {
                        myCommand.Parameters.AddWithValue("@contactNo1", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactNo1", mySchoolContactTable.ContactNo1);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.EmailAddress1))
                    {
                        myCommand.Parameters.AddWithValue("@emailAddress1", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@emailAddress1", mySchoolContactTable.EmailAddress1);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.FaxNumber1))
                    {
                        myCommand.Parameters.AddWithValue("@faxNumber1", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@faxNumber1", mySchoolContactTable.FaxNumber1);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.ContactRemark1))
                    {
                        myCommand.Parameters.AddWithValue("@contactRemark1", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactRemark1", mySchoolContactTable.ContactRemark1);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.ContactTitle2))
                    {
                        myCommand.Parameters.AddWithValue("@contactTitle2", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactTitle2", mySchoolContactTable.ContactTitle2);
                    }
                    if (mySchoolContactTable.ContactStatus1 == null)
                    {
                        myCommand.Parameters.AddWithValue("@contactStatus1", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactStatus1", mySchoolContactTable.ContactStatus1);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.ContactNo2))
                    {
                        myCommand.Parameters.AddWithValue("@contactNo2", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactNo2", mySchoolContactTable.ContactNo2);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.EmailAddress2))
                    {
                        myCommand.Parameters.AddWithValue("@emailAddress2", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@emailAddress2", mySchoolContactTable.EmailAddress2);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.FaxNumber2))
                    {
                        myCommand.Parameters.AddWithValue("@faxNumber2", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@faxNumber2", mySchoolContactTable.FaxNumber2);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.ContactRemark2))
                    {
                        myCommand.Parameters.AddWithValue("@contactRemark2", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactRemark2", mySchoolContactTable.ContactRemark2);
                    }
                    if (mySchoolContactTable.ContactStatus2 == null)
                    {
                        myCommand.Parameters.AddWithValue("@contactStatus2", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactStatus2", mySchoolContactTable.ContactStatus2);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.ContactTitle3))
                    {
                        myCommand.Parameters.AddWithValue("@contactTitle3", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactTitle3", mySchoolContactTable.ContactTitle3);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.ContactNo3))
                    {
                        myCommand.Parameters.AddWithValue("@contactNo3", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactNo3", mySchoolContactTable.ContactNo3);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.EmailAddress3))
                    {
                        myCommand.Parameters.AddWithValue("@emailAddress3", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@emailAddress3", mySchoolContactTable.EmailAddress3);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.FaxNumber3))
                    {
                        myCommand.Parameters.AddWithValue("@faxNumber3", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@faxNumber3", mySchoolContactTable.FaxNumber3);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.ContactRemark3))
                    {
                        myCommand.Parameters.AddWithValue("@contactRemark3", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactRemark3", mySchoolContactTable.ContactRemark3);
                    }
                    if (mySchoolContactTable.ContactStatus3 == null)
                    {
                        myCommand.Parameters.AddWithValue("@contactStatus3", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactStatus3", mySchoolContactTable.ContactStatus3);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.ContactTitle4))
                    {
                        myCommand.Parameters.AddWithValue("@contactTitle4", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactTitle4", mySchoolContactTable.ContactTitle4);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.ContactNo4))
                    {
                        myCommand.Parameters.AddWithValue("@contactNo4", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactNo4", mySchoolContactTable.ContactNo4);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.EmailAddress4))
                    {
                        myCommand.Parameters.AddWithValue("@emailAddress4", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@emailAddress4", mySchoolContactTable.EmailAddress4);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.FaxNumber4))
                    {
                        myCommand.Parameters.AddWithValue("@faxNumber4", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@faxNumber4", mySchoolContactTable.FaxNumber4);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.ContactRemark4))
                    {
                        myCommand.Parameters.AddWithValue("@contactRemark4", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactRemark4", mySchoolContactTable.ContactRemark4);
                    }
                    if (mySchoolContactTable.ContactStatus4 == null)
                    {
                        myCommand.Parameters.AddWithValue("@contactStatus4", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactStatus4", mySchoolContactTable.ContactStatus4);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.ContactTitle5))
                    {
                        myCommand.Parameters.AddWithValue("@contactTitle5", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactTitle5", mySchoolContactTable.ContactTitle5);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.ContactNo5))
                    {
                        myCommand.Parameters.AddWithValue("@contactNo5", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactNo5", mySchoolContactTable.ContactNo5);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.EmailAddress5))
                    {
                        myCommand.Parameters.AddWithValue("@emailAddress5", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@emailAddress5", mySchoolContactTable.EmailAddress5);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.FaxNumber5))
                    {
                        myCommand.Parameters.AddWithValue("@faxNumber5", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@faxNumber5", mySchoolContactTable.FaxNumber5);
                    }
                    if (string.IsNullOrEmpty(mySchoolContactTable.ContactRemark5))
                    {
                        myCommand.Parameters.AddWithValue("@contactRemark5", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactRemark5", mySchoolContactTable.ContactRemark5);
                    }
                    if (mySchoolContactTable.ContactStatus5 == null)
                    {
                        myCommand.Parameters.AddWithValue("@contactStatus5", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactStatus5", mySchoolContactTable.ContactStatus5);
                    }
                    if (mySchoolContactTable.CreatedDateTime == null)
                    {
                        myCommand.Parameters.AddWithValue("@createdDateTime", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@createdDateTime", mySchoolContactTable.CreatedDateTime);
                    }
                    if (mySchoolContactTable.ModifiedDateTime == null)
                    {
                        myCommand.Parameters.AddWithValue("@modifiedDateTime", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@modifiedDateTime", mySchoolContactTable.ModifiedDateTime);
                    }

                    DbParameter returnValue;
                    returnValue = myCommand.CreateParameter();
                    returnValue.Direction = ParameterDirection.ReturnValue;
                    myCommand.Parameters.Add(returnValue);

                    myConnection.Open();
                    myCommand.ExecuteNonQuery();
                    result = Convert.ToInt32(returnValue.Value);
                    myConnection.Close();
                }
            }
            return result;
        }

        /// <summary>
        /// Deletes a SchoolContactTable from the database.
        /// </summary>
        /// <param name="schoolContactKey">The SchoolContactKey of the SchoolContactTable to delete.</param>
        /// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
        public static bool Delete(int schoolContactKey)
        {
            int result = 0;
            using (SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["sis.dbconn"].ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("sprocSchoolContactTableDeleteSingleItem", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    myCommand.Parameters.AddWithValue("@schoolContactKey", schoolContactKey);
                    myConnection.Open();
                    result = myCommand.ExecuteNonQuery();
                    myConnection.Close();
                }
            }
            return result > 0;
        }

        #endregion

        /// <summary>
        /// Initializes a new instance of the SchoolContactTable class and fills it with the data fom the IDataRecord.
        /// </summary>
        private static SchoolContactTable FillDataRecord(IDataRecord myDataRecord)
        {
            SchoolContactTable mySchoolContactTable = new SchoolContactTable();
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("SchoolContactKey")))
            {
                mySchoolContactTable.SchoolContactKey = myDataRecord.GetInt32(myDataRecord.GetOrdinal("SchoolContactKey"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("SchoolKey")))
            {
                mySchoolContactTable.SchoolKey = myDataRecord.GetInt32(myDataRecord.GetOrdinal("SchoolKey"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Contact1Title")))
            {
                mySchoolContactTable.Contact1Title = myDataRecord.GetString(myDataRecord.GetOrdinal("Contact1Title"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactNo1")))
            {
                mySchoolContactTable.ContactNo1 = myDataRecord.GetString(myDataRecord.GetOrdinal("ContactNo1"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("EmailAddress1")))
            {
                mySchoolContactTable.EmailAddress1 = myDataRecord.GetString(myDataRecord.GetOrdinal("EmailAddress1"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("FaxNumber1")))
            {
                mySchoolContactTable.FaxNumber1 = myDataRecord.GetString(myDataRecord.GetOrdinal("FaxNumber1"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactRemark1")))
            {
                mySchoolContactTable.ContactRemark1 = myDataRecord.GetString(myDataRecord.GetOrdinal("ContactRemark1"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactTitle2")))
            {
                mySchoolContactTable.ContactTitle2 = myDataRecord.GetString(myDataRecord.GetOrdinal("ContactTitle2"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactStatus1")))
            {
                mySchoolContactTable.ContactStatus1 = myDataRecord.GetBoolean(myDataRecord.GetOrdinal("ContactStatus1"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactNo2")))
            {
                mySchoolContactTable.ContactNo2 = myDataRecord.GetString(myDataRecord.GetOrdinal("ContactNo2"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("EmailAddress2")))
            {
                mySchoolContactTable.EmailAddress2 = myDataRecord.GetString(myDataRecord.GetOrdinal("EmailAddress2"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("FaxNumber2")))
            {
                mySchoolContactTable.FaxNumber2 = myDataRecord.GetString(myDataRecord.GetOrdinal("FaxNumber2"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactRemark2")))
            {
                mySchoolContactTable.ContactRemark2 = myDataRecord.GetString(myDataRecord.GetOrdinal("ContactRemark2"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactStatus2")))
            {
                mySchoolContactTable.ContactStatus2 = myDataRecord.GetBoolean(myDataRecord.GetOrdinal("ContactStatus2"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactTitle3")))
            {
                mySchoolContactTable.ContactTitle3 = myDataRecord.GetString(myDataRecord.GetOrdinal("ContactTitle3"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactNo3")))
            {
                mySchoolContactTable.ContactNo3 = myDataRecord.GetString(myDataRecord.GetOrdinal("ContactNo3"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("EmailAddress3")))
            {
                mySchoolContactTable.EmailAddress3 = myDataRecord.GetString(myDataRecord.GetOrdinal("EmailAddress3"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("FaxNumber3")))
            {
                mySchoolContactTable.FaxNumber3 = myDataRecord.GetString(myDataRecord.GetOrdinal("FaxNumber3"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactRemark3")))
            {
                mySchoolContactTable.ContactRemark3 = myDataRecord.GetString(myDataRecord.GetOrdinal("ContactRemark3"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactStatus3")))
            {
                mySchoolContactTable.ContactStatus3 = myDataRecord.GetBoolean(myDataRecord.GetOrdinal("ContactStatus3"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactTitle4")))
            {
                mySchoolContactTable.ContactTitle4 = myDataRecord.GetString(myDataRecord.GetOrdinal("ContactTitle4"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactNo4")))
            {
                mySchoolContactTable.ContactNo4 = myDataRecord.GetString(myDataRecord.GetOrdinal("ContactNo4"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("EmailAddress4")))
            {
                mySchoolContactTable.EmailAddress4 = myDataRecord.GetString(myDataRecord.GetOrdinal("EmailAddress4"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("FaxNumber4")))
            {
                mySchoolContactTable.FaxNumber4 = myDataRecord.GetString(myDataRecord.GetOrdinal("FaxNumber4"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactRemark4")))
            {
                mySchoolContactTable.ContactRemark4 = myDataRecord.GetString(myDataRecord.GetOrdinal("ContactRemark4"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactStatus4")))
            {
                mySchoolContactTable.ContactStatus4 = myDataRecord.GetBoolean(myDataRecord.GetOrdinal("ContactStatus4"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactTitle5")))
            {
                mySchoolContactTable.ContactTitle5 = myDataRecord.GetString(myDataRecord.GetOrdinal("ContactTitle5"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactNo5")))
            {
                mySchoolContactTable.ContactNo5 = myDataRecord.GetString(myDataRecord.GetOrdinal("ContactNo5"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("EmailAddress5")))
            {
                mySchoolContactTable.EmailAddress5 = myDataRecord.GetString(myDataRecord.GetOrdinal("EmailAddress5"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("FaxNumber5")))
            {
                mySchoolContactTable.FaxNumber5 = myDataRecord.GetString(myDataRecord.GetOrdinal("FaxNumber5"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactRemark5")))
            {
                mySchoolContactTable.ContactRemark5 = myDataRecord.GetString(myDataRecord.GetOrdinal("ContactRemark5"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactStatus5")))
            {
                mySchoolContactTable.ContactStatus5 = myDataRecord.GetBoolean(myDataRecord.GetOrdinal("ContactStatus5"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("CreatedDateTime")))
            {
                mySchoolContactTable.CreatedDateTime = myDataRecord.GetDateTime(myDataRecord.GetOrdinal("CreatedDateTime"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ModifiedDateTime")))
            {
                mySchoolContactTable.ModifiedDateTime = myDataRecord.GetDateTime(myDataRecord.GetOrdinal("ModifiedDateTime"));
            }
            return mySchoolContactTable;
        }
    }

}
